import {useParams,useSearchParams,useNavigate,useLocation} from 'react-router-dom';
function WithRouter(Component){
    function NewComponent(props){
        let params = useParams();
        let SearchParams = useSearchParams();
        let navigate = useNavigate();
        let location = useLocation();
        let active = 0;
        // 监听路由
        switch(location.pathname){
            case '/index/home':
                active=0;
                break;
            case '/index/cart':
                active=1;
                break;
            case '/index/mine':
                active=2;
                break;
            default:
                active = 0;
        }
        return <Component {...props} router={{params,SearchParams,navigate,location}} active={active}></Component>
    }

    return NewComponent;
}


export default WithRouter;